package com.ac.cv.client.menu;

import com.ac.cv.client.KeyWord;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TreeItem;


/**
 * A label with click management
 * @author CHATELLIER
 *
 */
public abstract class ClickableLabel extends Label implements ClickHandler, KeyWord{

	private TreeItem treeParent;
	
	public ClickableLabel(){
		this.addClickHandler(this);
		this.addStyleName("label");
	}
	
	public ClickableLabel(String text){
		this();
		this.setText(text);
	}
	
	public void onClick(ClickEvent event) {
		History.newItem(ClickableLabel.this.getText(), false);
	}
	
	/**
	 * Executed when a click is simulated on the label
	 */
	public abstract void onSelect();

	public void setTreeParent(TreeItem treeParent) {
		this.treeParent = treeParent;
	}

	public TreeItem getTreeParent() {
		return treeParent;
	}
	
}
